﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.BLL
{
    /// <summary>
    /// 业务逻辑LinkType的简要说明。
    /// </summary>
    public class LinkType
    {
        /// <summary>
        /// 组织机构DAL
        /// </summary>
        private readonly DAL.LinkType dal = new DAL.LinkType();


        /// <summary>
        /// 是否存在该记录
        /// </summary>
        /// <creator>chenly</creator>
        /// <date>2013-7-12</date>
       /// <param name="fLinkTypeCD">友情链接编号</param>
       /// <param name="fEntityNo">公司编号</param>
       /// <returns>是否存在</returns>
        public bool Exists(string fLinkTypeCD, string fEntityNo)
        {
            return dal.Exists(fLinkTypeCD, fEntityNo);
        }


        /// <summary>
        /// 删除一条数据
        /// </summary>
        /// <creator>chenly</creator>
        /// <date>2013-7-12</date>
        /// <param name="fLinkTypeCD">友情链接编号</param>
        /// <param name="fEntityNo">公司编号</param>
        public void Del(string fLinkTypeCD, string fEntityNo)
        {

            dal.Del(fLinkTypeCD, fEntityNo);
        }

        /// <summary>
        /// 更新一条数据
        /// <creator>chenly</creator>
        /// <date>2013-7-12</date>
        /// </summary>
        /// <param name="model">一个model对象</param>

        public bool Update(ElingOA6_Admin_DSJCJ.Model.LinkType model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 增加一条数据
        /// <creator>chenly</creator>
        /// <date>2013-7-12</date>
        /// </summary>
       /// <param name="model">一个model对象</param>
        public void Add(Model.LinkType model)
        {
            dal.Add(model);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <creator>chenly</creator>
        /// <date>2013-7-12</date>
        /// <param name="strWhere">查询条件</param>
        /// <returns>DataTableToList</returns>
        public List<ElingOA6_Admin_DSJCJ.Model.LinkType> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return DataTableToList(ds.Tables[0]);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <creator>chenly</creator>
        /// <date>2013-7-12</date>
        /// <param name="dt">表</param>
        /// <returns>LinkType modelList</returns>
        public List<ElingOA6_Admin_DSJCJ.Model.LinkType> DataTableToList(DataTable dt)
        {
            List<ElingOA6_Admin_DSJCJ.Model.LinkType> modelList = new List<ElingOA6_Admin_DSJCJ.Model.LinkType>();
            int rowsCount = dt.Rows.Count;
            if (rowsCount > 0)
            {
                ElingOA6_Admin_DSJCJ.Model.LinkType model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new ElingOA6_Admin_DSJCJ.Model.LinkType();
                    model.FLinkTypeCD = dt.Rows[n]["FLinkTypeCD"].ToString();

                    model.FLinkTypeName = dt.Rows[n]["FLinkTypeName"].ToString();
                    model.FEntityNo = dt.Rows[n]["FEntityNo"].ToString();
                    model.FLinkProp = dt.Rows[n]["FLinkProp"].ToString();
                    modelList.Add(model);
                }
            }
            return modelList;
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        /// <param name="fLinkTypeCD">友情链接编号</param>
        /// <param name="fEntityNo">公司编号</param>
        /// <returns>Model</returns>
        public ElingOA6_Admin_DSJCJ.Model.LinkType GetModel(string fLinkTypeCD, string fEntityNo)
        {

            return dal.GetModel(fLinkTypeCD, fEntityNo);
        }


        /// <summary>
        /// 获得数据列表
        /// <creator>wangl</creator>
        /// <date>2013-09-09</date>
        /// </summary>
        public List<Model.LinkType> GetAllList(string entityNo)
        {
            DataSet ds = dal.GetAllList(entityNo);
            return DataTableToList(ds.Tables[0]);
        }


    }
}
